A short one:
Command
lsof -i -P -n | grep LISTEN
This will output all the ports the system is listing on. You might have to prepend “sudo”.
So then the command will be:
sudo lsof -i -P -n | grep LISTEN
The list is long without the “grep”, it will filter the output and only show the lines which contain “LISTEN”.
Edit:
Oliver from Hubzilla (part of the Fediverse) pointed out that
netstat -anpl
might be helpful too. The command shows all the listing sockets of the Linux machine it is run on. (I added the “l” parameter to just show listing sockets.